import * as monaco from 'monaco-editor'

/** 示例 */
// const apiType = `const context = {
//   /**
//    * @param {*} code
//    * @returns {Instance} 返回Instance实例
//    */
//   getInstance(){}
// }`

export const createTips = async (language: string, tips?: string) => {
  const libUri = ''

  if (language == 'javascript') {
    const libUriJquery = 'ts:filename/jquery.d.ts'

    const uriObjJquery = monaco.Uri.parse(libUri)
    const curModelJquery = monaco.editor.getModel(uriObjJquery)
    if (!curModelJquery) {
      const urlJquery = new URL('./components/jquery.txt', import.meta.url).href
      const libSourceJquery = await (await fetch(urlJquery)).text()
      monaco.editor.createModel(
        libSourceJquery,
        language,
        monaco.Uri.parse(libUriJquery)
      )
    }
  }

  if (tips) {
    monaco.editor.createModel(tips, language)
  }
}
